-- loadfile 先加载需要手动执行
local run_tbl = loadfile("table.lua")
if run_tbl then
	run_tbl()
end
-- dofile 直接执行
dofile("table.lua")

-- load
-- lua5.4废弃了loadstring
local chunk, err = load('print("Hello, world!")', "my_script", "t")
if chunk then
	chunk()
else
	print("Error:", err)
end

-- pcall:安全模式下运行
local function divide(a, b)
	if b == 0 then
		error("Division by zero!")
	end
	return a / b
end

local success, result = pcall(divide, 10, 0)
if success then
	print("Result:", result)
else
	print("Error:", result)
end

local tbl = { ["a"] = 1 }
tbl["ad"] = 123
for k, v in pairs(tbl) do
	print(k, v)
end

